import { screen } from 'electron';
import type { Point } from 'electron';

export function transformDisplayScale(_width: number, _height: number) {
  const { width, height } = screen.getPrimaryDisplay().workAreaSize;
  const baseWidth = 1920;
  const baseHeight = 1080;

  // 计算缩放因子
  const widthScaleFactor = width / baseWidth;
  const heightScaleFactor = height / baseHeight;

  // 选择较小的缩放因子，以保持宽高比
  const scaleFactor = Math.min(widthScaleFactor, heightScaleFactor);
  return {
    width: Math.round(_width * scaleFactor),
    height: Math.round(_height * scaleFactor)
  };
}

export function centerDisplayPoint(_width: number, _height: number): Point {
  const primaryDisplay = screen.getPrimaryDisplay();
  const { width, height } = primaryDisplay.workAreaSize;
  return {
    x: Math.round(width / 2 - _width / 2),
    y: Math.round(height / 2 - _height / 2)
  };
}
